package com.xuwang.service.impl;

import com.xuwang.pojo.ComplaintsAccept;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.xuwang.mapper.ComplaintsMapper;
import com.xuwang.pojo.Complaints;
import com.xuwang.service.ComplaintsService;

@Service
public class ComplaintsServiceImpl implements ComplaintsService {

    @Resource
    private ComplaintsMapper complaintsMapper;

    @Override
    public int deleteByPrimaryKey (Integer id) {
        return complaintsMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert (Complaints record) {
        return complaintsMapper.insert(record);
    }

    @Override
    public int insertOrUpdate (Complaints record) {
        return complaintsMapper.insertOrUpdate(record);
    }

    @Override
    public int insertOrUpdateSelective (Complaints record) {
        return complaintsMapper.insertOrUpdateSelective(record);
    }

    @Override
    public Map<String, Object> insertSelective (Complaints record) {
        record.setComplaintsTime(new Date());
        System.out.println(record);
        complaintsMapper.insertSelective(record);
        Map<String, Object> map = new HashMap<>();
        map.put("code", 200);   // 前端端分离时，前端人员会首先判断code值是否满足200，如果不是200，则提醒用户失败
        map.put("msg", "新增成功");
        return map;
    }

    @Override
    public Complaints selectByPrimaryKey (Integer id) {
        return complaintsMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective (Complaints record) {
        return complaintsMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey (Complaints record) {
        return complaintsMapper.updateByPrimaryKey(record);
    }

    @Override
    public int updateBatch (List<Complaints> list) {
        return complaintsMapper.updateBatch(list);
    }

    @Override
    public int updateBatchSelective (List<Complaints> list) {
        return complaintsMapper.updateBatchSelective(list);
    }

    @Override
    public int batchInsert (List<Complaints> list) {
        return complaintsMapper.batchInsert(list);
    }

}


